<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=8">
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <title></title>
    <script type="text/javascript" charset="utf-8" src="../../../editor_config.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../editor_api.js">
        paths = [
            'editor.js',
            'core/browser.js',
            'core/utils.js',
            'core/EventBase.js',
            'core/dom/dom.js',
            'core/dom/dtd.js',
            'core/dom/domUtils.js',
            'core/dom/Range.js',
            'core/dom/Selection.js',
            'core/Editor.js',
            'commands/inserthtml.js',
            'commands/image.js',
            'commands/insertimage.js',
            'commands/justify.js',
            'commands/font.js',
            'commands/link.js',
            'commands/removeformat.js',
            'commands/blockquote.js',
            'commands/indent.js',
            'commands/print.js',
            'commands/preview.js',
            'commands/selectall.js',
            'commands/paragraph.js',
            'commands/directionality.js',
            'commands/horizontal.js',
            'commands/time.js',
            'commands/inserthtml.js',
            'commands/rowspacing.js',
            'commands/cleardoc.js',
            'commands/anchor.js',
            'commands/delete.js',
            'commands/wordcount.js',
            'plugins/pagebreak/pagebreak.js',
            'plugins/undo/undo.js',
            'plugins/paste/paste.js',
            'plugins/list/list.js',
            'plugins/source/source.js',
            'plugins/shortcutkeys/shortcutkeys.js',
            'plugins/enterkey/enterkey.js',
            'plugins/keystrokes/keystrokes.js',
            'plugins/fiximgclick/fiximgclick.js',
            'plugins/autolink/autolink.js',
            'plugins/highlight/highlight.js',
            'plugins/serialize/serialize.js',
            'plugins/video/video.js',
            'plugins/table/table.js',
            'plugins/contextmenu/contextmenu.js',
            'plugins/pagebreak/pagebreak.js',
            'plugins/basestyle/basestyle.js',
            'plugins/formatmatch/formatmatch.js',
            'plugins/searchreplace/searchreplace.js',
            'ui/ui.js',
            'ui/uiutils.js',
            'ui/uibase.js',
            'ui/separator.js',
            'ui/mask.js',
            'ui/popup.js',
            'ui/colorpicker.js',
            'ui/tablepicker.js',
            'ui/stateful.js',
            'ui/button.js',
            'ui/splitbutton.js',
            'ui/colorbutton.js',
            'ui/tablebutton.js',
            'ui/toolbar.js',
            'ui/menu.js',
            'ui/combox.js',
            'ui/dialog.js',
            'ui/menubutton.js',
            'ui/datebutton.js',
            'ui/editorui.js',
            'ui/editor.js',
            'ui/multiMenu.js'
        ];
    </script>

    <style type="text/css">
        #editor {
            border: 1px solid #CCC;
            width:240px;
            float:left;
            margin-left:20px;
        }
        #editor_toolbar_box {
            background: #F0F0EE;
            padding: 2px;
        }
        #editor_iframe_holder {
            border-top: 1px solid #CCC;
            border-bottom: 1px solid #CCC;
            position: relative;
        }
        .left {
            float:left;
        }
        .content{
            width:300px;
            height:150px;
            border:1px solid #2e8b57;
            padding:5px;
        }
    </style>
</head>
<body>
    <div class="left">

        <select id="enterTag" onchange="createEditor()">
            <option>选择编辑器插件</option>
            <option value="br">回车使用br标签</option>
            <option value="p">回车使用p标签</option>
            <option value="paste">粘贴纯文本插件</option>
        </select>
        <div id="showSource" class="content">

        </div>
    </div>
    <div id="editor">
        <div id="editor_toolbar_box">
            <input id="sourceBtn" type="button" value="查看源码" onclick="myeditor.execCommand('source')"/>
        </div>
        <div id="editor_iframe_holder"></div>
    </div>
    <script type="text/javascript" charset="utf-8">
        var myeditor;
        //创建编辑器
        function createEditor(){
            myeditor = null;
            var enterTag = document.getElementById("enterTag").value;
            var option = changeOption();

            myeditor = new baidu.editor.Editor(option);
            myeditor.addListener('sourcemodechanged', function (t, mode){
                var sourceBtn = document.getElementById("sourceBtn");
                if (mode) {
                    sourceBtn.value = "查看内容";
                } else {
                    sourceBtn.value = "查看源码";
                }
            });
            myeditor.addListener('aftersetcontent', function (){
                myeditor.body.focus();
            });
            myeditor.render('editor_iframe_holder');



            document.getElementById("showSource").innerHTML = option.showText;
        }
        if(!myeditor){
            myeditor = new baidu.editor.Editor({
                initialContent: 'hello world',//初始化编辑器的内容
                minFrameHeight: 200,
                UEDITOR_HOME_URL:'../../../',
                iframeCssUrl :'../../../themes/default/iframe.css',
                sourceEditor: 'textarea',
                elementPathEnabled:false,
                autoHeightEnabled:false
            });
            myeditor.addListener('sourcemodechanged', function (t, mode){
                var sourceBtn = document.getElementById("sourceBtn");
                if (mode) {
                    sourceBtn.value = "查看内容";
                } else {
                    sourceBtn.value = "查看源码";
                }
            });
            myeditor.addListener('aftersetcontent', function (){
                myeditor.body.focus();
            });

            //渲染编辑器
            myeditor.render('editor_iframe_holder');

            document.getElementById("showSource").innerHTML = "//创建编辑器：<br>myeditor = new baidu.editor.Editor({<br>initialContent: 'hello world'<br>});";
        }
        function changeOption(){
            var plugs = document.getElementById("enterTag");
            var option = {
                initialContent : "编辑器  hello world",
                minFrameHeight: 200,
                UEDITOR_HOME_URL:'../../../',
                iframeCssUrl :'../../../themes/default/iframe.css',
                sourceEditor: 'textarea',
                elementPathEnabled:false,
                autoHeightEnabled:false
            };
            switch(plugs.value){
                case "br":
                    option.enterTag = "br";
                    option.plugins = ['enterkey', 'source'];
                    option.showText = "//创建编辑器：<br>myeditor = new baidu.editor.Editor({<br>plugins: [ 'source','enterkey' ],<br>enterTag : '"+option.enterTag+"'  //回车标签<br>});";
                    break;
                case "p" :
                    option.enterTag = "p";
                    option.plugins = ['enterkey', 'source'];
                    option.showText = "//创建编辑器：<br>myeditor = new baidu.editor.Editor({<br>plugins: [ 'source','enterkey' ],<br>enterTag : '"+option.enterTag+"'<br>});";
                    break;
                case "paste" :
                    option.pasteplain = true;
                    option.plugins = ['paste', 'source'];
                    option.showText = "//创建编辑器：<br>myeditor = new baidu.editor.Editor({<br>plugins: [ 'source','paste' ],<br>pasteplain : true<br>});";
                    break;
                default :
                    option.showText = "//创建编辑器：<br>myeditor = new baidu.editor.Editor({<br>initialContent: 'hello world'<br>});";
            }
            return option;
        }
    </script>
</body>
</html>